<template>
  <!-- 通知通告统计页面 -->
  <div>
    车厂未读列表
    <!-- table -->
    <FilterTable
      height="300"
      ref="oemNoReadTable"
      :columns="oemNoReadColumns"
      :fetchapi="fetchapi"
      :params="oemNoReadParams"
      :isSelectColumn="isSelectColumn"
      :datakey="'records'"
      :onColumnsChange="oemNoReadColumns => this.oemNoReadColumns = oemNoReadColumns"
    >

      <template slot="controls">
        <el-button size="small" type="primary" icon="el-icon-download" @click="downOemNoRead">下载</el-button>
      </template>
    </FilterTable>

    经销商未读列表
    <!-- table -->
    <FilterTable
      height="300"
      ref="dealerNoReadTable"
      :columns="dealerNoReadColumns"
      :fetchapi="fetchapi"
      :params="dealerNoReadParams"
      :isSelectColumn="isSelectColumn"
      :datakey="'records'"
      :onColumnsChange="dealerNoReadColumns => this.dealerNoReadColumns = dealerNoReadColumns"
    >
      <template slot="controls">
        <el-button size="small" type="primary" icon="el-icon-download" @click="downDealerRead">下载</el-button>
      </template>
    </FilterTable>

    <div class="dialogBottmView">
      <el-button @click="closeDialog()">关 闭</el-button>
    </div>

  </div>
</template>

<script>
import { pageNotificationFeedback ,exportNotificationFeedback } from '@/api/admin/notice/dcsNoticeStat/index';
import { dictionary } from '@/utils/dictMixin';
import { exportExcelFile } from '@/utils';

export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      oemNoReadColumns:this.createOemReadColumns(),
      oemReadList:null,
      dealerNoReadColumns:this.createDealerReadColumns(),
      dealerReadList:null,
      isSelectColumn:false,
      oemNoReadParams:{
        notificationId:this.value.notificationId,
        type:3,
        isDealer :0, // 不是
        status :25641002 // 未读
      },
      dealerNoReadParams:{
        notificationId:this.value.notificationId,
        type:4,
        isDealer :1, // 不是
        status :25641002 // 未读
      },
      fetchapi:pageNotificationFeedback
    };
  },
  methods: {
    createOemReadColumns(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        { title: '用户名', dataIndex: 'feedbackUserName', sorter: true }
      ];
    },
    createDealerReadColumns(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.$index + 1}</span>;
          }
        },
        { title: '经销商代码', dataIndex: 'ownerCode', sorter: true },
        { title: '经销商名称', dataIndex: 'dealerName', sorter: true },
        { title: '员工姓名', dataIndex: 'feedbackUserName', sorter: true }
      ];
    },
    async downOemNoRead(){
      await exportNotificationFeedback(this.oemNoReadParams).then(res=>{exportExcelFile(res.data,"车厂未读列表.xls")});
    },
    async downDealerRead(){
      await exportNotificationFeedback(this.dealerNoReadParams).then(res=>{exportExcelFile(res.data,"经销商未读列表.xls")});
    },
    // 关闭当前页面操作
    closeDialog(type){
      this.$emit('close', { visible: false ,type:type});
    },
  }
};
</script>
<style lang="less" scoped>
</style>
